package ca.utoronto.utm.csc301.euchre.gamemanager;

import java.util.List;
import java.util.ArrayList;

import ca.utoronto.utm.csc301.euchre.common.Card;
import ca.utoronto.utm.csc301.euchre.common.Suit;
import ca.utoronto.utm.csc301.euchre.common.Rank;


/**
 *
 */
public class Deck {
	private List<Card> cards;

	/**
	 * Populate the deck with all possible cards.
	 */
	private void createCards() {
		cards = new ArrayList<Card>();
	
		for (Rank r: Rank.values()) {
			for (Suit s: Suit.values()) {
				cards.add(Card.getCard(s, r));
			}
		}
	}
	
	public Deck() {
		createCards();
	}
	
	/**
	 * Return the amount of Cards in this Deck.
	 * @return the amount of Cards in this Deck
	 */
	public int countCards() {
		return cards.size();
	}
	
	/**
	 * Pop a random Card from this Deck, returning that card.
	 * @return a randomly popped card from this deck
	 */
	public Card popCard() {
		return cards.remove(EuchreManager.getRandom(cards.size() - 1));
	}
}
